home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / infosrvr / dev / libhtml_.tar / libwww / HTUtils.h < prev    next >
C/C++ Source or Header  |  1993-01-20  |  5KB  |  218 lines

  1. /*    Macros for general use                    HTUtils.h
  2. **
  3. **    See also: the system dependent file "tcp.h"
  4. */
  5.  
  6. #ifndef HTUTILS_H
  7. #define HTUTILS_H
  8.  
  9. #ifdef SHORT_NAMES
  10. #define WWW_TraceFlag HTTrFlag
  11. #endif
  12.  
  13. /*    Debug message control.
  14. */
  15. #ifndef STDIO_H
  16. #include <stdio.h>
  17. #define STDIO_H
  18. #endif
  19.  
  20. #ifdef DEBUG
  21. #define TRACE (WWW_TraceFlag)
  22. #define PROGRESS(str) printf(str)
  23.     extern int WWW_TraceFlag;
  24. #else
  25. #define TRACE 0
  26. #define PROGRESS(str) /* nothing for now */
  27. #endif
  28.  
  29. #define CTRACE if(TRACE)fprintf
  30. #define tfp stdout
  31.  
  32.  
  33. /*    Standard C library for malloc() etc
  34. */
  35. #ifdef vax
  36. #ifdef unix
  37. #define ultrix    /* Assume vax+unix=ultrix */
  38. #endif
  39. #endif
  40.  
  41. #ifndef VMS
  42. #ifndef ultrix
  43. #ifdef NeXT
  44. #include <libc.h>    /* NeXT */
  45. #endif
  46. #ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */
  47. #include <stdlib.h>    /* ANSI */
  48. #endif
  49. #else /* ultrix */
  50. #include <malloc.h>
  51. #include <memory.h>
  52. #include <stdio.h>
  53. #endif
  54.  
  55. #else    /* VMS */
  56. #include <stdio.h>
  57. #include <ctype.h>
  58. #endif
  59.  
  60. #define PUBLIC            /* Accessible outside this module     */
  61. #define PRIVATE static        /* Accessible only within this module */
  62.  
  63. #ifdef __STDC__
  64. #define CONST const        /* "const" only exists in STDC */
  65. #define NOPARAMS (void)
  66. #define PARAMS(parameter_list) parameter_list
  67. #define NOARGS (void)
  68. #define ARGS1(t,a) \
  69.         (t a)
  70. #define ARGS2(t,a,u,b) \
  71.         (t a, u b)
  72. #define ARGS3(t,a,u,b,v,c) \
  73.         (t a, u b, v c)
  74. #define ARGS4(t,a,u,b,v,c,w,d) \
  75.         (t a, u b, v c, w d)
  76. #define ARGS5(t,a,u,b,v,c,w,d,x,e) \
  77.         (t a, u b, v c, w d, x e)
  78. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
  79.         (t a, u b, v c, w d, x e, y f)
  80. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
  81.         (t a, u b, v c, w d, x e, y f, z g)
  82. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
  83.         (t a, u b, v c, w d, x e, y f, z g, s h)
  84. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
  85.         (t a, u b, v c, w d, x e, y f, z g, s h, r i)
  86. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
  87.         (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)
  88.  
  89. #else  /* not ANSI */
  90.  
  91. #define CONST
  92. #define NOPARAMS ()
  93. #define PARAMS(parameter_list) ()
  94. #define NOARGS ()
  95. #define ARGS1(t,a) (a) \
  96.         t a;
  97. #define ARGS2(t,a,u,b) (a,b) \
  98.         t a; u b;
  99. #define ARGS3(t,a,u,b,v,c) (a,b,c) \
  100.         t a; u b; v c;
  101. #define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
  102.         t a; u b; v c; w d;
  103. #define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
  104.         t a; u b; v c; w d; x e;
  105. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
  106.         t a; u b; v c; w d; x e; y f;
  107. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
  108.         t a; u b; v c; w d; x e; y f; z g;
  109. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) (a,b,c,d,e,f,g,h) \
  110.         t a; u b; v c; w d; x e; y f; z g; s h;
  111. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) (a,b,c,d,e,f,g,h,i) \
  112.         t a; u b; v c; w d; x e; y f; z g; s h; r i;
  113. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) (a,b,c,d,e,f,g,h,i,j) \
  114.         t a; u b; v c; w d; x e; y f; z g; s h; r i q j;
  115.         
  116.     
  117. #endif /* __STDC__ (ANSI) */
  118.  
  119. #ifndef NULL
  120. #define NULL ((void *)0)
  121. #endif
  122.  
  123.  
  124. /* Note: GOOD and BAD are already defined (differently) on RS6000 aix */
  125. /* #define GOOD(status) ((status)&1)     VMS style status: test bit 0          */
  126. /* #define BAD(status)  (!GOOD(status))     Bit 0 set if OK, otherwise clear   */
  127.  
  128. #ifndef BOOLEAN_DEFINED
  129.     typedef char    BOOLEAN;        /* Logical value */
  130. #ifndef CURSES
  131. #ifndef TRUE
  132. #define TRUE    (BOOLEAN)1
  133. #define    FALSE    (BOOLEAN)0
  134. #endif
  135. #endif
  136. #define BOOLEAN_DEFINED
  137. #endif
  138.  
  139. #ifndef BOOL
  140. #define BOOL BOOLEAN
  141. #endif
  142. #ifndef YES
  143. #define YES (BOOLEAN)1
  144. #define NO (BOOLEAN)0
  145. #endif
  146.  
  147. #ifndef min
  148. #define min(a,b) ((a) <= (b) ? (a) : (b))
  149. #define max(a,b) ((a) >= (b) ? (a) : (b))
  150. #endif
  151.  
  152. #define TCP_PORT 80    /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
  153. #define OLD_TCP_PORT 2784    /* Try the old one if no answer on 80 */
  154. #define DNP_OBJ 80    /* This one doesn't look busy, but we must check */
  155.  
  156. /*    Inline Function WHITE: Is character c white space? */
  157.  
  158. #ifndef NOT_ASCII
  159. #define WHITE(c) (((unsigned char)(c))<=' ')    /* Assumes ASCII but faster */
  160. #else
  161. #define WHITE(c) ( ((c)==' ') || ((c)=='\t') || ((c)=='\n') || ((c)=='\r') )
  162. #endif
  163.  
  164. #define HT_LOADED (29999)        /* Instead of a socket */
  165.  
  166. #include "HTString.h"  /* String utilities */
  167.  
  168. #ifdef __STDC__
  169. #include <stdarg.h>
  170. #else
  171. #include <varargs.h>
  172. #endif
  173.  
  174. #ifdef CURSES
  175.     /* htbrowse.c; */
  176. #include <curses.h>
  177.  
  178.     extern        WINDOW  *w_top, *w_text, *w_prompt;
  179.     extern        void    user_message PARAMS((const char *fmt, ...));
  180.     extern        void    prompt_set PARAMS((CONST char * msg));
  181.     extern        void    prompt_count PARAMS((long kb));
  182. #else
  183. #define user_message printf
  184. #endif
  185.  
  186. /*    Out Of Memory checking for malloc() return:
  187. */
  188. #ifndef __FILE__
  189. #define __FILE__ ""
  190. #define __LINE__ ""
  191. #endif
  192.  
  193. #define outofmem(file, func) \
  194.  { fprintf(stderr, "%s %s: out of memory.\nProgram aborted.\n", file, func); \
  195.   exit(1);}
  196. /* extern void outofmem PARAMS((const char *fname, const char *func)); */
  197.  
  198.  
  199. extern void msg_init PARAMS((int height));
  200. extern void msg_printf PARAMS((int y, const char *fmt, ...));
  201. extern void msg_exit PARAMS((int wait_for_key));
  202.  
  203. /*    Upper- and Lowercase macros
  204. **
  205. **  The problem here is that toupper(x) is not defined officially unless
  206. **  isupper(x) is.  These macros are CERTAINLY needed on
  207. **  #if defined(pyr) || define(mips) or BDSI platforms.
  208. ** For safefy, we make them mandatory.
  209. */
  210. #ifndef TOLOWER
  211.   /* Pyramid and Mips can't uppercase non-alpha */
  212. #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
  213. #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
  214. #endif /* ndef TOLOWER */
  215.  
  216. #endif /* HTUTILS_H */
  217.  
  218.